package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.dto.*;
import com.tbit.uqbike.object.pojo.vo.RechargeGiveDetailVO;
import com.tbit.uqbike.object.pojo.vo.RechargeGiveIncomeVO;
import com.tbit.uqbike.object.pojo.vo.RechargeGiveTotalDetailVO;
import com.tbit.uqbike.object.pojo.vo.RechargeGiveTotalIncomeVO;
import com.tbit.common.entity.view.PageResult;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.service.business.RechargeGiveStatService;
import com.tbit.uqbike.webmanager.util.csv.annotations.AsyncDownload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 财务统计-充值赠送统计
 *
 * @AUTHOR: wei.xing
 * @DATE: 2022-11-23 17:10
 **/
@RequestMapping("/rechargeGiveStat")
@RestController
public class RechargeGiveStatController {

    @Autowired
    RechargeGiveStatService service;


    /**
     * 获取充值赠送统计按天统计的总详情
     *
     * @param dto
     * @return
     */
    @GetMapping("/getTotalDetail")
    public Result<RechargeGiveTotalDetailVO> getTotalDetail(StatDetailDTO dto) {
        RechargeGiveTotalDetailVO detailVO = service.getTotalDetail(dto);
        return Result.success(detailVO);
    }


    /**
     * 获取充值赠送统计按天统计的分页
     *
     * @param dto
     * @return
     */
    @GetMapping("/getDetailPage")
    public Result<PageResult<RechargeGiveDetailVO>> getDetailPage(StatDetailPageDTO dto) {
        PageResult<RechargeGiveDetailVO> page = service.getDetailPage(dto);
        return Result.success(page);
    }

    /**
     * 充值赠送统计按天统计的账单下载
     *
     * @param dto
     * @return
     */
    @AsyncDownload(defaultFileName = "充值赠送统计按天统计")
    @PostMapping("/exportDetail")
    public Result exportDetail(@RequestBody StatDetailDownloadDTO dto) {
        String url = service.exportDetail(dto);
        return Result.success(url);
    }

    /**
     * 获取充值赠送统计用户赠送详情的汇总
     *
     * @param dto
     * @return
     */
    @GetMapping("/getIncomeTotalDetail")
    public Result<RechargeGiveTotalIncomeVO> getTotalIncome(RechargeGiveIncomeDTO dto) {
        RechargeGiveTotalIncomeVO detailVO = service.getTotalIncome(dto);
        return Result.success(detailVO);
    }

    /**
     * 获取充值赠送统计用户赠送详情的分页
     *
     * @param dto
     * @return
     */
    @GetMapping("/getIncomeDetailPage")
    public Result<PageResult<RechargeGiveIncomeVO>> getIncomePage(RechargeGiveIncomePageDTO dto) {
        PageResult<RechargeGiveIncomeVO> pageResult = service.getIncomePage(dto);
        return Result.success(pageResult);
    }


    /**
     * 充值赠送统计用户赠送详情的账单下载
     *
     * @param dto
     * @return
     */
    @AsyncDownload(defaultFileName = "赠送统计用户赠送详情")
    @PostMapping("/exportIncomeDetail")
    public Result exportIncome(@RequestBody RechargeGiveIncomeDownloadDTO dto) {
        String url = service.exportIncome(dto);
        return Result.success(url);
    }
}
